<?php

declare(strict_types=1);

namespace app\validate\settlement;

use think\Validate;

class InvoiceValidate extends Validate
{
    protected $rule = [
        'statement_id' => 'require|integer|gt:0',
        'seller_org_id' => 'integer|gt:0',
        'invoice_no' => 'max:80',
        'invoice_type' => 'max:20',
        'amount' => 'float|gt:0',
        'tax_rate' => 'float|egt:0',
        'tax_amount' => 'float|egt:0',
        'invoice_url' => 'max:255',
        'status' => 'in:0,1,2',
        'reject_reason' => 'max:255',
    ];

    protected $scene = [
        'create' => [
            'statement_id',
            'seller_org_id',
            'invoice_no',
            'invoice_type',
            ['amount', 'require|float|gt:0'],
            'tax_rate',
            'tax_amount',
            'invoice_url',
        ],
        'update' => ['status', 'invoice_no', 'invoice_type', 'amount', 'tax_rate', 'tax_amount', 'invoice_url', 'reject_reason'],
    ];
}
